﻿using UnityEngine;

//消耗钥匙后打开的门
public class LockedDoor : MonoBehaviour
{
    [SerializeField] 
    private int num_keyNeeded;
    private Character player;

    private void Awake()
    {
        player = Character.Instance;
    }

    private void OnCollisionEnter2D(Collision2D collision)
    {
        if(collision.gameObject.GetComponent<Character>() != null && player.keyCount >= num_keyNeeded)
        {
            player.keyCount -= num_keyNeeded;
            Destroy(gameObject);
        }
    }
}
